package com.zuoye.Serviecs;

import com.zuoye.entity.Account;
import com.zuoye.extend.Coemmt;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/14  16:54
 * @Copyright
 */
public class Back extends Coemmt {
    public static Account[] accounts = new Account[3];


    public Back() {
        accounts[0] = new Account("123", "123456", 13323) {


            @Override
            public double deposit(double money, String number, String password) {
                return 0;
            }
        };
        accounts[1] = new Account("456", "234567", 23355) {


            @Override
            public double deposit(double money, String number, String password) {
                return 0;
            }
        };
        accounts[2] = new Account("789", "345678", 33544) {


            @Override
            public double deposit(double money, String number, String password) {
                return 0;
            }
        };

    }

    public Account verify(String number, String password) {
        for (int i = 0; i < accounts.length; i++) {
            if (accounts[i].getCardNo().equals(number) && accounts[i].getPassword().equals(password)) {
                System.out.println("账户正确，欢迎使用！");
                return accounts[i];
            }

        }


        return null;
    }


    public int Menus(int count) {
        System.out.println("-----------------------------------------");
        do {
            System.out.println("请选择选项：1.存款 2.取款  3.退出");
            count = scanner.nextInt();
            return count;
        } while (true);

    }



    public void saveMoney(Account account, double money) {

        account.save(money);

    }









    public void depositMoney(double money, int index, String number, String password) {
        do {

            if (index == 1) {
                SavingAcount savingAcount = new SavingAcount();
                savingAcount.deposit(money,number,password);
                break;
            }else if (index == 2 ) {
                CreitAccount creitAccount = new CreitAccount();
                creitAccount.loan(money,number,password);
            }else if (index <= 0 &&  index > 3 ){
                System.out.println("对不起，没有该选项！");
            }
         break;
        }while (true);
    }
}

